package com.eascs.ant.data.mongo.entity;

import java.util.HashMap;
import java.util.Map;


public class MongoPageQuery<T> extends PageQuery<T> {

	private static final long serialVersionUID = 5857391873103986286L;

	private Map<String, Object> params = new HashMap<>();
	
	private Map<String, Object> sorts = new HashMap<>();
	
	private String[] returnFields;//指定返回的字段
	
	private String[] NoReturnFields;//指定不需要返回的字段,两者只能取一
	
	private String collectionName;


	public String[] getReturnFields() {
		return returnFields;
	}

	public void setReturnFields(String[] returnFields) {
		//AssertErrorUtils.assertNull(this.NoReturnFields, "指定返回字段跟不返回的字段两者只能取其一！");
		this.returnFields = returnFields;
	}

	public String[] getNoReturnFields() {
		return NoReturnFields;
	}

	public void setNoReturnFields(String[] noReturnFields) {
		//AssertErrorUtils.assertNull(this.returnFields, "指定返回字段跟不返回的字段两者只能取其一！");
		this.NoReturnFields = noReturnFields;
	}

	public void setParams(Map<String, Object> params) {
		this.params = params;
	}

	public void setSorts(Map<String, Object> sorts) {
		this.sorts = sorts;
	}

	public MongoPageQuery(Class<T> returnType, int pageSize, int pageIndex) {
		super(returnType, pageSize, pageIndex);
	}

	public MongoPageQuery<T> addParam(String name, Object value) {
		params.put(name, value);
		return this;
	}

	public MongoPageQuery<T> addParams(Map<String, Object> params) {
		this.params.putAll(params);
		return this;
	}

	public Map<String, Object> getParams() {
		return params;
	}

	public String getCollectionName() {
		return collectionName;
	}

	public void setCollectionName(String collectionName) {
		this.collectionName = collectionName;
	}

	public void addSort(String name, Integer sortType) {
		this.sorts.put(name, sortType);
	}

	public void addSorts(Map<String, Integer> sorts) {
		this.sorts.putAll(sorts);
	}

	public Map<String, Object> getSorts() {
		return sorts;
	}

	@Override
	public String toString() {
		return "MongoPageQuery [params=" + params + ", sorts=" + sorts + ", collectionName=" + collectionName + ", toString()=" + super.toString() + "]";
	}

}
